Skip to content

opentelemetry-api: fix SelectableGroups deprecation warning#5250

Open
herin049 wants to merge 2 commits into
open-telemetry:mainfrom
herin049:fix/selectable-groups-warning
Open

opentelemetry-api: fix SelectableGroups deprecation warning#5250
herin049 wants to merge 2 commits into
open-telemetry:mainfrom
herin049:fix/selectable-groups-warning

Conversation

@herin049
Copy link
Copy Markdown
Contributor

Description

Fixes bug where deprecation warnings are raised when calling _as_entry_points on Python versions 3.10/3.11.

Fixes #5231

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py310-test-opentelemetry-api

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 requested a review from a team as a code owner May 26, 2026 23:52
@herin049 herin049 changed the title fix SelectableGroups deprecation warning opentelemetry-api: fix SelectableGroups deprecation warning May 26, 2026
@herin049 herin049 moved this to Ready for review in Python PR digest May 26, 2026
Comment on lines +32 to +40
# Python 3.10 entry_points() returns a dict-like SelectableGroups object.
# Use dict.values() instead of eps.values() to avoid the DeprecationWarning
# that SelectableGroups raises when calling .values().
if isinstance(eps, dict):
return EntryPoints(itertools.chain.from_iterable(dict.values(eps)))
# Fallback for all other types
return EntryPoints(
ep for group in eps.groups for ep in eps.select(group=group)
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused on the cases being handled here. I thought the first isinstance check would cover everything >3.10.

Could you just add a comment at each branch indicating what python version and why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line covers >3.11

if isinstance(eps, EntryPoints):
    return eps

This line covers 3.10 and 3.11.

if isinstance(eps, dict):
    return EntryPoints(itertools.chain.from_iterable(dict.values(eps)))

This line should be unreachable in our supported version range, but I've kept it just in case.

return EntryPoints(
    ep for group in eps.groups for ep in eps.select(group=group)
)

I will add a comment. Thanks for the review!

@aabmass aabmass moved this from Ready for review to Approved PRs that need fixes in Python PR digest Jun 5, 2026
@aabmass
Copy link
Copy Markdown
Member

aabmass commented Jun 5, 2026

FYI I turned on auto merge for once all conversations are resolved

@aabmass aabmass enabled auto-merge June 5, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Importing opentelemetry.context issues a warning in Python 3.10 and 3.11

2 participants